/********************************
 * ETK - Easy ToolKit
 * Copyright (C) 2007-2008 Ekinoks (scv.ekinoks@gmail.com)
 * All rights reserved.
 *
 *    This file is part of ETK.
 *
 *    Foobar is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    Foobar is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with Foobar; if not, write to the Free Software
 *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 ***********************************************************************************/

#ifndef __ETK_STATEMODEL_H__
#define __ETK_STATEMODEL_H__

#include <iostream>

namespace etk
{
    class State;

    /** Modelise les states valides
    *
    */
    class StateModel
    {
        private :
            inline bool getBit(int bit) const
            {
                return state_ & (1 << bit);
            }

            inline void setBit(int bit)
            {
                state_ |= (1 << bit);
            }

        protected :
            StateModel(long int state) : state_(state)
            {
            }

            /*
 	        SHIFT           = 1 << 0
 	        CAPS_LOCK       = 1 << 1
 	        CTRL            = 1 << 2
 	        ALT             = 1 << 3
 	        NUM_LOCK        = 1 << 4
 	        SCROLL_LOCK     = 1 << 5
 	        SUPER           = 1 << 6
 	        ALTGR           = 1 << 7
 	        BUTTON1         = 1 << 8
 	        BUTTON2         = 1 << 9
 	        BUTTON3         = 1 << 10
 	        BUTTON4         = 1 << 11
 	        BUTTON5         = 1 << 12

 	        NO_SHIFT        = 1 << 19
 	        NO_CAPS_LOCK    = 1 << 20
 	        NO_CTRL         = 1 << 21
 	        NO_ALT          = 1 << 22
 	        NO_NUM_LOCK     = 1 << 23
 	        NO_SCROLL_LOCK  = 1 << 24
 	        NO_SUPER        = 1 << 25
 	        NO_ALTGR        = 1 << 26
 	        NO_BUTTON1      = 1 << 27
 	        NO_BUTTON2      = 1 << 28
 	        NO_BUTTON3      = 1 << 29
 	        NO_BUTTON4      = 1 << 30
 	        NO_BUTTON5      = 1 << 31
 	        */
            long int state_;

        public :

            StateModel operator+ (const StateModel & s) const;              // appelle de +=

            StateModel& operator+= (const StateModel & s) /*non const*/;    // implementation

            StateModel operator- (const StateModel & s) const;              // appelle de +

            StateModel& operator-= (const StateModel & s) /*non const*/;    // appelle de +=

            bool operator== (const StateModel& state) const;                // implementation

            bool operator!= (const StateModel& state) const;                // appelle de ==

            bool operator== (const State& stateModel) const;                // implementation

            bool operator!= (const State& stateModel) const;                // appelle de ==

            /** Selectionner comme model que le boutton a appuyer
            *
            */
            StateModel onlyPressed() const;

            /** Selectionner comme model que le boutton a ne pas appuyer
            *
            */
            StateModel onlyUnpressed() const;

            /** Selectionner comme model que les lock (num / caps / scroll)
            *
            */
            StateModel onlyLock() const;

            /** Ne pas selectionner comme model les lock
            *
            */
            StateModel onlyUnlock() const;

            /** on doit appuyer exactement sur les meme touche que le model
            *
            */
            StateModel only() const;

            static const StateModel ANY;
            static const StateModel SHIFT;
            static const StateModel CAPS_LOCK;
            static const StateModel CTRL;
            static const StateModel ALT;
            static const StateModel NUM_LOCK;
            static const StateModel SCROLL_LOCK;
            static const StateModel SUPER;
            static const StateModel ALTGR;
            static const StateModel BUTTON1;
            static const StateModel BUTTON2;
            static const StateModel BUTTON3;
            static const StateModel BUTTON4;
            static const StateModel BUTTON5;
    };

}

#endif // __ETK_STATEMODEL_H__

